package org.wlw.utils;

import java.sql.*;

public class DBUtil {
    public static Connection getConnection() {
        try {
            String username = "23wlw";
            String password = "123";
            String url = "jdbc:mysql://localhost:3306/23wlw_base";
            Connection con = DriverManager.getConnection(url,username,password);
            return con;
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void close(Connection connection) {
        try {
            if(connection!=null) connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void close(PreparedStatement ps) {
        try {
            if(ps!=null) ps.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public static void close(ResultSet rs) {
        try {
            if(rs!=null) rs.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
